<template>
    <div class="big">
        <el-button  icon="el-icon-arrow-left" @click="back"></el-button>
        <div class="rotate">
            <div id="main"></div>
        </div>
    </div>
</template>

<script>
// 引入 ECharts 主模块
import echarts from 'echarts/lib/echarts';
// 引入柱状图
require('echarts/lib/chart/bar');
// 引入提示框和标题组件
require('echarts/lib/component/tooltip');
require('echarts/lib/component/title');
export default {
    data(){
        return {
            
        }
    },
    mounted(){
        var myChart = echarts.init(document.getElementById('main'));
        
        var res=sessionStorage.getItem('numList');
        let numList = JSON.parse(res);
        let codeList = numList.codeList;
        let saveList = numList.saveList;
        
        myChart.setOption({
            title: {
            text: '现存量',
        },
        tooltip: {
        formatter: (s)=>{
            var re= '';
            var length = s.name.length;
            for (var i = 0,j=1; i < length; i++,j++) {
                if (j&&j % 10 == 0) {
                    re += '<br />';
                } else {
                    re += s.name[i];
                }
            }
            return re;
        }
    },
        legend: {
            data: ['现存量']
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: codeList
        },
        series: [
            {
                name: '',
                type: 'bar',
                data:saveList
            }
        ]
        });
    },
    methods:{
        back(){
            this.$router.push('/Sale');
            sessionStorage.setItem("numList",'')
        }
    }
}
</script> 

<style>
.big{
    width: 100vw;
    height: 100vh;
    overflow: scroll;
}
.rotate{
    width: 100%;
    height:95%; 
}
#main{
    width: 100%;
    height:100%;
}

</style>
